// 随机函数
const randomNum = (min, max) => parseInt(Math.random() * (max - min + 1) + min, 10);
const getRandomColor = () => 'rgb(' + randomNum(0, 255) + ',' + randomNum(0, 255) + ',' + randomNum(0, 255) + ')';


const state = {
    row: 4,
    col: 4,
    colorNumber: 4,
};
const getters = {
    Colors(state) {
        var _color = [];
        var colorList = [];
        for (let i = 0; i < state.colorNumber; i++) {
            _color.push(getRandomColor());
        };
        for (let i = 0; i < state.row; i++) {
            var _colorItem = [];
            for (let i = 0; i < state.col; i++) {
                _colorItem.push(_color[randomNum(0, _color.length - 1)]);
            };
            colorList.push(_colorItem);
        }
        return colorList;
    },
};
const mutations = {
    setRunderPageConfig(state, options) {
        state.row = options.row;
        state.col = options.col;
        state.colorNumber = options.colorNumber;
    }
};
const actions = {

};
export default {
    namespaced: true,
    state,
    getters,
    mutations,
    actions
}